<?php

class Application_View_Helper_LanguageSwitcher extends Zend_View_Helper_Abstract {
    public function languageSwitcher() {
        $request   = Zend_Controller_Front::getInstance()->getRequest();
        $baseUrl   = $this->view->baseUrl();
        
        //Zend_Debug::dump($request->getPathInfo());
        
	//$baseUrl   = rtrim($baseUrl, '/') . '/' . $request->getPathInfo();
        
        $queries = $request->getQuery();
        
        $query   = '';
        if (is_array($queries) && count($queries) > 0) {
                $query = '?' . http_build_query($queries);
        }
        
        $output = '';
        
        $output .= '<a href="' . rtrim($baseUrl, '/') . '/ru/' . ltrim($request->getPathInfo(), '/') . $query . '" title="RUS" class="button_ru"><img src="/img/ru.png" alt="Russia" /></a>';
        $output .= '<a href="' . rtrim($baseUrl, '/') . '/en/' . ltrim($request->getPathInfo(), '/') . $query . '" title="ENG" class="button_en"><img src="/img/eng.png" alt="English" /></a>';
        return $output;
    }
}
